package com.fantabest.frontend.client.widget;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.fantabest.common.client.ColumnModelManager;
import com.fantabest.common.client.StoreManager;
import com.fantabest.common.client.widget.PlayersPanel;

public class TeamPlayersPanel extends PlayersPanel {
	@Override
	protected Grid<BeanModel> createGrid(String position) {
		final String p = position;
		final EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(StoreManager
				.getInstance().getPlayersStore(position), ColumnModelManager
				.getInstance().getEditablePlayersCM());
		grid.setAutoExpandColumn("lastname");
		grid.setLoadMask(true);
		grid.addListener(Events.Attach, new Listener<GridEvent<BeanModel>>() {
			public void handleEvent(GridEvent<BeanModel> be) {
				grid.getStore().getLoader().load();
				grid.getStore().filter(p);
			}
		});
		grid.setHeight(300);
		return grid;
	}
}
